/*
    Copyright (C) 2010 2011 Rémi Thebault

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include <iostream>
#include <thread>

#include <QApplication>
#include <QLocale>
#include <QTranslator>
#include <QTextCodec>
#include <QFile>
#include <QString>

#include <procycle/version.h>

#include "procycle.h"


int main(int argc, char *argv[])
{

    QApplication app(argc, argv);

    app.setApplicationName("ProCycle");
    app.setApplicationVersion(PC::VERSION_STRING);

    QString locale = QLocale::system().name();
    QTranslator translator;
    translator.load(QString(":/tr/procycle_")+locale);
    QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
    app.installTranslator(&translator);

    QFile styleFile (":/procycle.qss");
    if (styleFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
        QString styleSheet (styleFile.readAll());
        app.setStyleSheet(styleSheet);
    }

    std::cout << "ProCycle v" << PC::VERSION_STRING.toStdString() <<" - "<<
                 QApplication::tr("A cycle diagram builder").toStdString() << "\n"
                 "Copyright (c) 2010 2011 2012 Remi Thebault\n" <<
                 QApplication::tr("This program comes with ABSOLUTELY NO WARRANTY.").toStdString() << "\n" <<
                 QApplication::tr("It is free software, and you are welcome to redistribute"
                                  " it under certain conditions.").toStdString() << "\n" <<
                 QApplication::tr("See http://www.gnu.org/licenses/gpl-3.0-standalone.html"
                                  " for details.").toStdString() << std::endl;
    ProCycle pc (argc, argv);

    return app.exec();
}
